package com.cnbm.wcsbasic.protocol.netty.modbus.codec;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import com.cnbm.wcsbasic.protocol.netty.io.common.Package;


/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2024-06-06 10:45
 */
public class ModbusTcpEncode extends MessageToByteEncoder {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Object o, ByteBuf byteBuf) throws Exception {
        Package aPackage = (Package) o;
        ByteBuf dataByteBuf = Unpooled.copiedBuffer(aPackage.getBody());
        byteBuf.writeBytes(dataByteBuf);
    }
}
